package com.ym.manager.admin.goods;

import com.ym.manager.admin.goods.model.GoodsCategory;
import com.ym.manager.sys.model.AdminUser;
import com.ym.utils.Pages;
import com.ym.utils.ResultUtil;
import com.ym.web.bind.CurrentUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @program: ym-admin->GoodsCategoryController
 * @Auther: 但何非
 * @Date: 2019/11/27 09:20
 * @Description: 类目
 */
@Controller
@RequestMapping("/goodsCategory")
public class GoodsCategoryController {
    @Autowired
    private GoodsCategoryService goodsCategoryService;

    @RequestMapping("/getCategoryList")
    @ResponseBody
    public String getCategoryList(@RequestParam(defaultValue = "-1") int pid, @CurrentUser AdminUser user){
        Map<String, Object> result = ResultUtil.result();
        try {
            result.put("data",goodsCategoryService.getCategoryList(pid));
        }catch (Exception e){
            e.printStackTrace();
            result.put("code",-1000);
            result.put("msg","系统异常");
        }
        return ResultUtil.toJSON(result);
    }

}
